<html>
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  <title>
    测试
  </title>
</head>
<script type="text/javascript">
  // 这里的参数随便你整了
  function testCall() {
    alert(window.external.JSExternal("testCall", "xarg1, xarg2"))
  }

  function runScript() {
    window.external.JSExternal("runScript", "alert('hello!')")
  }
  
 

  document.onkeydown=function(event){
     var e = event || window.event || arguments.callee.caller.arguments[0];
     if(e && e.keyCode==27){
       alert("esc")
     }if(e && e.keyCode==113){ // 按 F2
        alert("f2")
     }if(e && e.keyCode==13){ // enter 键
        alert("enter")
     }
  };

 
 
 

  
  
</script>

<body>
<button onclick="alert('hello!');">alert</button><br /><br />
<button onclick="testCall();">testCall</button><br /><br />
<button onclick="runScript();">runScript</button><br /><br />
<input value="test">
</body>
</html>